﻿@model PagedList<ADZ_SupplierMaster>
@{
    ViewBag.Title = "供应商列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    SupplierListQueryModel paramModel = new SupplierListQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (SupplierListQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("supplierlist", "supplier")" method="get">
    <div class="form_query">
        <div>
            供应商名称：
            <input type="text" name="supplier_name" id="supplier_name" class="abc input-default" placeholder="" value="@paramModel.supplier_name">&nbsp;
        </div>
        <div>
            供应商类型：
            <select id="supplier_type" name="supplier_type">
                <option value="-10" @(paramModel.supplier_type == -10 ? "selected" : "")>全部类型</option>
                @{
                    dc = new Dictionary<string, string>();
                    var list = dbcontext.ADZ_SupplierType.ToList();
                    foreach (var item in list)
                    {
                        dc.Add(item.supplier_type.ToString(), item.supplier_type_name);
                    }
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.supplier_type.ToString());
            </select>&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("add","supplier")'">新增</button>
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th style="width:40px"><input type="checkbox" name="chkall" id="chkall" />全选</th>
            <th>编号</th>
            <th>供应商名称</th>
            <th>营业执照</th>
            <th>供应商类型</th>
            <th>联系人姓名</th>
            <th>手机号码</th>
            <th>email</th>
            <th>QQ</th>
            <th>地址</th>
            <th>状态</th>
            <th>负责人</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
<tr class="@HtmlPagerHelper.TrClass(index)">
    <td>
        <input type="checkbox" name="cbx_last" value="@m.supplier_id" />
    </td>
    <td>@m.supplier_id</td>
    <td>@m.supplier_name</td>
    <td>
        <a class="list-img" href="@ImageFileBiz.GetImg(m.zhizhao_url)" target="_blank"> <img style="width:30px;margin:1px 1px 1px 1px;" src="@ImageFileBiz.GetImg(m.zhizhao_url,"small")" /></a>
    </td>
    <td>
        @{
            var suppliertype = dbcontext.ADZ_SupplierType.FirstOrDefault(t => t.supplier_type == m.supplier_type);
            if (suppliertype != null)
            {
                <info>
                    @suppliertype.supplier_type_name
                </info>
            }
        }
    </td>
    <td>@m.contact_name</td>
    <td>@m.telephone</td>
    <td>@m.email</td>
    <td>@m.qq</td>
    <td>@m.city_name @m.supplier_address </td>
    <td>
        @switch (m.status)
        {
            case 0:
                @:卖家可编辑
                break;
            case 3:
                @:卖家已编辑
                break;
            case 8:
                @:审核驳回
                break;
        }
    </td>
    <td>
        <info class="green">@m.manage_name</info>
    </td>
    <td>@m.create_date.ToString(1)</td>
    <td>
        <a href="@Url.Action("add", "supplier", new { id = m.supplier_id})">编辑</a>
        @*<a href="javascript:void(0);" onclick="toDel(@m.supplier_id)">删除</a>*@
    </td>
</tr>
        }
        <tr>
            <td colspan="20">
                <a href="javascript:void(0);" onclick="modifymanager()">更改负责人</a>
            </td>
        </tr>
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    reloadHandler = function () {
                        window.location.reload();
                    }

                    function toDel(id) {
                        BUI.Message.Show({
                            title: '提示',
            msg: '确定要删除该供应商吗?',
            icon: 'question',
            buttons: [
                                {
                                text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                                    url = "@Url.Action("ToDel", "supplier")";
                                    parameter = { id: id };
                      $.post(url, parameter, function (result) {
                                        ShowActionResult(result, reloadHandler);
                                    });
                                    this.close();
                                }
                            },
              {
                                text: '取消',
                  elCls: 'button',
                  handler: function () {
                                    this.close();
                                }
                            }

            ]
        });
    }

    //选择页面回调方法
    function getNewLinkValue(RealName, UID) {
        var ids = getCheckboxList();
        var url = "@Url.Action("BindManager", "supplier")";
        var parameter = {
            ids: ids,
            manager_uid: UID
        };
        $.post(url, parameter, function (result) {
            ShowActionResult(result, reloadHandler);
        });
    }
    function modifymanager() {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择调整的供应商", 'warning');
            return;
        }
        window.open('/Common/SelectManagerUser?RoleId=0', '', 'height=570px,width=850px,fullscreen=no,resizable=no,scrollbars=no,location=no,status=no,top=50,left=250')
    }

</script>

